﻿using System;
using System.Windows.Forms;

namespace Tapioca.Views
{
	public partial class FindAndReplaceWindow : Form
	{
		public FindAndReplaceWindow()
		{
			this.InitializeComponent();
		}

				
		private void UpdateView()
		{
            //this.search.Text = this.Presenter.TextToFind;
            //this.replace.Text = this.Presenter.TextToReplace;
            //this.matchCaseOption.Checked = this.Presenter.CaseSensitive;
            //this.matchWordOption.Checked = this.Presenter.MatchWord;
		}

		private void OnSearchKeyUp(object sender, KeyEventArgs e)
		{
			//this.Presenter.TextToFind = this.search.Text;
		}

		private void OnReplaceKeyUp(object sender, KeyEventArgs e)
		{
			//this.Presenter.TextToReplace = this.replace.Text;
		}

		private void OnOptionChanged(object sender, EventArgs e)
		{
            //this.Presenter.CaseSensitive = this.matchCaseOption.Checked;
            //this.Presenter.MatchWord = this.matchWordOption.Checked;
		}

		private void OnClosing(object sender, FormClosingEventArgs e)
		{
			//this.Presenter.CancelFindCommand.Invoke();
		}

		private void OnFormKeyUp(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				this.Close();
			}
		}

        private void btnFindNext_Click(object sender, EventArgs e)
        {
            ((MainForm)this.Owner).xmlTextEditor.Find(this.search.Text, this.matchWordOption.Checked);
        }

        private void btnReplace_Click(object sender, EventArgs e)
        {
            ((MainForm)this.Owner).xmlTextEditor.Replace(this.search.Text, this.replace.Text, this.matchWordOption.Checked);
        }

        private void btnReplaceAll_Click(object sender, EventArgs e)
        {
            ((MainForm)this.Owner).xmlTextEditor.ReplaceAll(this.search.Text, this.replace.Text, this.matchWordOption.Checked);
        }
	}
}